<template>
	<view>
		<!-- 头部 -->
		<view class="header">
			<icons @click="backBeforePage" type="left" color="white" size="22"></icons>
			<view class="">支付完成</view>
		</view>
		<view class="big_pic">
			<image src="/static/image/di@3x.png" mode=""></image>
			<image class="finish" src="/static/wancheng@3x.png" mode=""></image>
			<view class="box">
				<text class="t1">支付成功</text>
				<text class="t2">已支付￥{{money}}</text>
			</view>
			<image class="bigOne" src="/static/image/zhingjia@3x.png" mode=""></image>
			<image class="smallOne" src="/static/image/wanchengtupian@3x.png" mode=""></image>
		</view>
		<view class="button_box">
			<text>立即分享&nbsp;领取豪礼</text>
			<button class="btn1">立即分享</button>
			<button class="btn2" @click="toHome">返回首页</button>
		</view>
	</view>
</template>

<script>
	import icons from "@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue";
	import {getOpenVipApi} from "../../../apis/mine.js"
	import {getUserInfo} from "../../../apis/user.js"
	export default {
		onLoad(options){
			this.money = options.money
			this.date = options.date
			this.setVipData()
		},
		data() {
			return {
				money:"",
				date:""
			};
		},
		components: {
			icons
		},
		methods:{
			//返回上一页
			backBeforePage() {
				uni.navigateBack()
			},
			//返回首页
			toHome(){
				uni.switchTab({
					url:"/pages/home/home"
				})
			},
			//发送会员信息到后端
			setVipData(){
				const {_id} = uni.getStorageSync("userInfo")
				const token = uni.getStorageSync("token")
				const date = this.date
				getOpenVipApi({_id,date}).then(res => {
					getUserInfo({
						token
					}).then(res => {
						const userInfo = res[0]
						uni.setStorageSync("userInfo", userInfo)
					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
//头部
	.header {
		width: 100%;
		height: 150rpx;
		background-color: #ffae25;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 1;

		view {
			padding-top: 25rpx;
			line-height: 160rpx;
			text-align: center;
			color: #ffffff;
			font-size: 36rpx;
			font-weight: 550;
		}

		icons {
			position: absolute;
			top: 80rpx;
			left: 20rpx
		}
	}
	//大图
	.big_pic{
		position: relative;
		height: 624rpx;
		image{
			width: 100%;
			height: 100%;
		}
		.finish{
			width: 120rpx;
			height: 120rpx;
			position: absolute;
			top: 168rpx;
			left: 320rpx;
		}
		.box{
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			position: absolute;
			top: 300rpx;
			left: 300rpx;
			.t1{
				font-size: 36rpx;
				color: #ffffff;
			}
			.t2{
				padding-top: 10rpx;
				font-size: 32rpx;
				color: #ffc37e;
			}
		}
		.bigOne{
			width: 314rpx;
			height: 314rpx;
			position: absolute;
			top: 412rpx;
			left: 218rpx;
		}
		.smallOne{
			width: 250rpx;
			height: 250rpx;
			position: absolute;
			top: 444rpx;
			left: 250rpx;
		}
	}
	.button_box{
		margin-top: 160rpx;
		height: 320rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: center;
		text{
			font-size: 40rpx;
			color: #2f2f2f;
		}
		.btn1{
			width: 542rpx;
			height: 90rpx;
			background-image: linear-gradient(270deg, #ffae25 0%, #ff8e1d 100%);
			border-radius: 45rpx;
			color: #ffffff;
			font-size: 36rpx;
		}
		.btn2{
			width: 542rpx;
			height: 90rpx;
			border-radius: 45rpx;
			border: 2rpx solid #ff921e;
			box-sizing: border-box;
			font-size: 36rpx;
			color: #ff921e;
		}
	}
</style>
